package com.leyou.item.api;

import com.leyou.common.pojo.PageResult;
import com.leyou.item.bo.SpuBo;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.Spu;
import com.leyou.item.pojo.SpuDetail;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/*
    1、获取spu的接口，提供elasticsearch获取数据时调用的接口，继承该API调用item使用FeignClient、
    2、根据spuid获取spudetail详细信息
    3、根据spu查sku数据
 */

public interface GoodsApi {

    /**
     * 分页查询商品
     *
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("spu/page")
    PageResult<SpuBo> querySpuBoByPage( // 返回值是自己写的分页对象
                                        // 搜素的关键字，不必填
                                        @RequestParam(value = "key", required = false) String key,
                                        // 是否上架
                                        @RequestParam(value = "saleable", required = false) Boolean saleable,
                                        @RequestParam(value = "page", defaultValue = "1") Integer page,
                                        @RequestParam(value = "rows", defaultValue = "5") Integer rows
    );


    /**
     * 根据spuid查询SpuDetail信息（spu详情）
     *
     * @param pid
     * @return
     */
    @GetMapping("/spu/detail/{SpuId}")
    SpuDetail querySpuDetail(@PathVariable("SpuId") Long pid);


    /**
     * 根据spu查sku数据
     *
     * @param pid
     * @return
     */
    @GetMapping("sku/list")
    List<Sku> querySku(@RequestParam("id") Long pid);

    /**
     * 根据spu的id查询spu的信息
     */
    @GetMapping("spu/{id}")
    Spu querySpuById(@PathVariable Long id);


    @GetMapping("sku/{id}")
    Sku querySkuById(@PathVariable("id") Long id);
}
